package com.tencent.wxcloudrun.controller;

import com.github.pagehelper.PageInfo;
import com.tencent.wxcloudrun.model.OrderGoodsReq;
import com.tencent.wxcloudrun.model.PayReq;
import com.tencent.wxcloudrun.response.R;
import com.tencent.wxcloudrun.service.OrderGoodsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * ClassName: OrderGoodsController
 * Package: com.tencent.wxcloudrun.controller
 * Description:
 *
 * @Date: 2023/1/22 8:34 AM
 * @Author: wht
 */
@Slf4j
@RestController
@RequestMapping("/admin")
public class OrderGoodsController {
    @Autowired
    OrderGoodsService orderGoodsService;

    @PostMapping("/getOrderGoodsList")
    public <T> R<T> getOrderGoodsList(@RequestBody OrderGoodsReq req) {
        PageInfo orderPage = orderGoodsService.getOrderGoodsList(req);
        return R.successData(orderPage);
    }

    @GetMapping("/getOrderGoodsShow/{shop_id}")
    public <T> R<T> getOrderGoodsShow(@PathVariable("shop_id") Integer shop_id) {
        List<PayReq> res = orderGoodsService.getOrderGoodsShow(shop_id);
        return R.successData(res);
    }

    @PostMapping("/updateOrderGoodsStatus")
    public <T> R<T> updateOrderGoodsStatus(@RequestBody Map body) {
        Integer id = (Integer) body.get("id");
        Integer status = (Integer) body.get("status");
        orderGoodsService.updateOrderGoodsStatus(id, status);
        return R.successMsg("修改成功！");
    }


}
